﻿#pragma once

#include <learn/ais/ais_mesh.h>
#include <learn/ais/ais_renderer.h>

namespace xi
{

namespace painter
{

using namespace xi::ais;

class EXT_SYMBOL Paint_Context;

class EXT_SYMBOL Renderer : public AIS_Renderer
{
  protected:
    Paint_Context *m_ctx;

  public:
    /**
     * @brief 默认构造函数
     *
     * @param[in] ctx
     */
    Renderer(Paint_Context *ctx);

    /**
     * @brief 绘制物体
     *
     * @param[in] obj
     */
    void draw(AIS_Object *obj) const override;
};

class EXT_SYMBOL Mesh_Renderer : public Renderer
{
  public:
    /**
     * @brief 网格渲染器构造函数
     *
     * @param[in] ctx
     */
    Mesh_Renderer(Paint_Context *ctx);

    /**
     * @brief 刷新渲染器
     *
     * @param[in] obj
     */
    void update(AIS_Object *obj) override;

    /**
     * @brief 绘制物体
     *
     * @param[in] obj
     */
    void draw(AIS_Object *obj) const override;

  public:
    unsigned int diffuseTex;  // 散射纹理
    unsigned int specularTex; // 镜面纹理

  protected:
    std::size_t m_count;                           // 记录网格顶点数量
    std::function<Mesh_Data(AIS_Object *)> m_data; // 网格数据获取函数
};

} // namespace painter

} // namespace xi
